<#include "header.html">
<script type="text/javascript">
(function(){
	var permi={
		chkFunc : function(obj, code){
			var flag = $(obj).prop("checked")? true : false;
			$("input[name=func_"+code+"]").prop("checked",flag);;
		},
		chkMenu : function(obj, code){
			if(obj.checked){
				$("#menu_"+code).prop("checked",true);
			}
		}
	};
	
	window.Permission=permi;	
})(window);

$(function(){
	$("#moduleCode").change(function(){
		location.href = "sysRoleAction.do?method=confAuth&dataId="+$("#roleId").val()+"&moduleCode="+$(this).val();
	});
});
</script>

<div class="c_nav">
	<span>管理选项：</span>
	<a href="sysRoleAction.do?method=query&parentCode=${role.parentCode}&roleLevel=${role.roleLevel}">返回角色列表</a>
	<a href="javascript:location.reload()"> | [刷新页面]</a>
</div>
<div class="c_box bg_white">
	<form id="authForm" name="authForm" action="?method=saveAuth" method="post">
	<div class="c_topic"><b class="e_red">${role.roleName}</b>权限配置</div>
	<div class="c_form_3 c_form-label-8">
		<ul class="l_mb">
			<li>
				<span class="e_label e_label-required">当前配置模块：</span>
				<span class="e_select">
					<select id="moduleCode" name="moduleCode">
					<#list moduleList as m>
						<option value="${m.menuCode}" <#if m.menuCode==moduleCode> selected="selected"</#if>>${m.menuName!}</option>
					</#list>
					</select>
				</span>
			</li>
		</ul>
	</div>
	<div class="c_table e_left l_mt">
		<table>
        	<thead>
			<tr class="e_center">
				<th>菜单节点</th>
				<th>菜单名称</th>
				<th>功能操作</th>
			</tr>
            </thead>
            <tbody>
            <#assign tmpCode="0">
            <#list menuList as m>
			<tr>
				<#if tmpCode!=m.PARENT_CODE>
				<td class="e_center" rowspan="${m.MENU_NUM!}" >${m.PARENT_MENU!}</td>
				</#if>
				<td>
				<input type="hidden" name="node_${m.MENU_CODE}" value="${m.PARENT_CODE!}"/>
				<label><input type="checkbox" id="menu_${m.MENU_CODE}" name="menuCode" value="${m.MENU_CODE}" <#if hasFunc[m.MENU_CODE]??> checked="checked"</#if> onClick="javascript:Permission.chkFunc(this, '${m.MENU_CODE}');" />${m.MENU_NAME!}</label>
				</td>
				<td>
				<#list menuFunc[m.MENU_CODE] as f>
				<label><input type="checkbox"  name="func_${m.MENU_CODE}" value="${f.FUNC_CODE}" onClick="javascript:Permission.chkMenu(this, '${m.MENU_CODE}');" <#if hasFunc[m.MENU_CODE]?? && hasFunc[m.MENU_CODE]?index_of(f.FUNC_CODE)!=-1>checked="checked"</#if>/>${f.FUNC_NAME!}</label>&nbsp;&nbsp;
				</#list>
				</td>
			</tr>
			<#assign tmpCode=m.PARENT_CODE>
			</#list>
            </tbody>
		</table>
	</div>	
	
	<div class="e_center">
		<input type="hidden" name="roleId" id="roleId" value="${role.id!}"/>
		<input type="hidden" name="roleLevel" id="roleLevel" value="${role.roleLevel}"/>
		<input type="hidden" name="parentCode" id="parentCode" value="${role.parentCode}"/>
		<button type="button" bind="saveAuth" tradeAction="" bindForm="authForm" class="e_btn-page">提交</button>
		<button type="reset" class="e_btn l_ml">重置</button>
	</div>
    </form>
</div>
<#include "footer.html">